﻿using System.Data.OracleClient;
using picFilter.App_Code;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;

namespace picFilter.Controllers
{
    public class typesController : ApiController
    {

        // GET api/types
        /// <summary>
        /// 获取所有证件类型
        /// </summary>
        /// <returns>[{rows}]</returns>
        public object Get()
        {
            try
            {
                DataTable dt = DBHelper.ExecuteDataTable("select * From type");
                return dt;
            }
            catch (Exception ex)
            {
                return new { error = "获取证件类型失败！", syserror = ex.Message };
            }
        }

        // GET api/types/5
        /// <summary>
        /// 获取指定证件类型
        /// </summary>
        /// <param name="id"></param>
        /// <returns>[{rows}]</returns>
        public object Get(int id)
        {
            try
            {
                OracleParameter ID = DBHelper.createParameter("ID", OracleType.Int32, id);
                DataTable dt = DBHelper.ExecuteDataTable("select * From type Where id=:ID", ID);
                return dt;
            }
            catch (Exception ex)
            {
                return new { error = "获取证件类型失败！", syserror = ex.Message };
            }
        }

        // POST api/types
        public void Post([FromBody]string value)
        {
        }

        // PUT api/types/5
        public void Put(int id, [FromBody]string value)
        {
        }

        // DELETE api/types/5
        public void Delete(int id)
        {
        }
    }
}
